package vn.edu.uit.chemistry.model;

import java.util.ArrayList;

import vn.edu.uit.chemistry.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class NhomAdapter extends BaseAdapter{
	Context ctx;
	LayoutInflater mInflater;
	
	ArrayList<Nhom> listNhom = new ArrayList<Nhom>();
	
	public NhomAdapter(Context _ctx, ArrayList<Nhom> _listNhom) {
		this.ctx = _ctx;
		mInflater = LayoutInflater.from(_ctx);
		this.listNhom = _listNhom;
	}
	
	public int getCount() {
		// TODO Auto-generated method stub
		return listNhom.size();
	}
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public class NhomHolder {
		TextView tvNhom;
		TextView tvIP;	
	}
	
	public View getView(int pos, View v, ViewGroup group) {
		NhomHolder holder;
		if (v == null) {
			v = mInflater.inflate(R.layout.row_nhom, null);
			holder = new NhomHolder();
			holder.tvNhom = (TextView) v.findViewById(R.id.tvNhom);
			holder.tvIP = (TextView) v.findViewById(R.id.tvIPNhom);
			
			v.setTag(holder);
		} else {
			holder = (NhomHolder) v.getTag();
		}
		
		holder.tvNhom.setText("Tên nhóm : " + listNhom.get(pos).getTenNhom());
		holder.tvIP.setText("IP : "+ listNhom.get(pos).getHost());
		return v;
	}
}
